import json
import time

from bottle import request, response, HTTPResponse

def validate_post_params(required_params, param_validators=None):
    def decorator(func):
        def wrapper(*args, **kwargs):
            try:
                data = request.json
            except ValueError:
                return HTTPResponse(status=400, body=json.dumps({"error": "Invalid JSON in request body"}))

            if not data:
                return HTTPResponse(status=400, body=json.dumps({"error": "No required parameters specified"}))
            missing_params = [param for param in required_params if param not in data]
            if missing_params:
                return HTTPResponse(status=400, body=json.dumps({"error": f"Missing parameters: {', '.join(missing_params)}"}))

            if param_validators:
                for param, validator in param_validators.items():
                    if param not in data or not validator(data[param]):
                        return HTTPResponse(status=400, body=json.dumps({"error": f"Invalid value for parameter '{param}'"}))

            return func(*args, **kwargs)
        return wrapper
    return decorator

def is_positive_integer(value):
    try:
        return isinstance(value, int) and value > 0
    except ValueError:
        return False
    
def is_valid_unix_timestamp(timestamp):
    try:
        time_tuple = time.localtime(timestamp)
        return timestamp == int(time.mktime(time_tuple))
    except (OverflowError, OSError):
        return False